<?php
namespace app\common\service\sms;

use think\facade\Cache;
use app\common\service\sms\AliyunSms;
class Index
{
	
	/**
	 * [短信验证码发送验证码-入口]
	 * Author：上官钧墨
	 * @param  [type] $mobile [手机号]
	 * @param  [type] $code   [验证码]
	 */
	public function sendSms($mobile,$code)
	{
		$sendType = 'AliyunSms';//发送类型，阿里云短信

		if ($sendType == 'AliyunSms') {
			$sms = $this->aliyunSmsSend($mobile,$code);
			return $sms;
		}
		
		
	}

	/**
	 * [阿里云短信-单条发送验证码]
	 * Author：上官钧墨
	 * @param  [type] $mobile [手机号]
	 * @param  [type] $code   [验证码]
	 */
	public function aliyunSmsSend($mobile,$code)
	{
		$accessKeyId = 'LTAI4GHJGvTEZDuC3efhmoSE';// 您的访问密钥id
		$accessKeySecret = 'LR1SsrmzkC5MfcBfyVapyKjta8wwl4';// 您的访问密钥密码
		// 单条发送
		$params=[
			'PhoneNumbers'=>$mobile,//短信接收号码
			"SignName"=>"D球村",//短信签名
			"TemplateCode"=>'SMS_211830162',//短信模板Code
			"TemplateParam"=>[//设置模板参数,模板中存在变量需要替换则为必填项
				"code" => $code,
		    ]
		];
		$AliSms = new AliyunSms;
		$status = $AliSms->sendSms($accessKeyId,$accessKeySecret,$params);
		if (strtolower($status['Code']) == 'ok') {
			return [
				'status'=>true,
				'message'=>'发送成功'
			];
		}
		return [
			'status'=>false,
			'message'=>$status['Message']
		];
	}




}
